<?php
/**
 * Created by PhpStorm.
 * User: luojinyi
 * Date: 2018/3/10
 * Time: 下午7:20
 */

namespace App\Http\Transformers;


use App\Models\RolesPermission;
use League\Fractal\TransformerAbstract;
use Spatie\Permission\Models\Role;

class SingleRoleTransformer extends TransformerAbstract
{
    public function transform(Role $role)
    {
        $data = $role->toArray();

        $data['permission'] = RolesPermission::where('role_id', $data['id'])->get();

        return $data;
    }
}
